import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login'
import Layout from '@/views/Layout'
import Search from '@/views/Search'
import SearchResultList from '@/views/Search/ResultList'
import ArticleDetail from '@/views/Article/detail.vue'
import UserEdit from '@/views/UserEdit'
import Home from '@/views/Layout/Home'
import User from '@/views/Layout/User'
import Chat from '@/views/chat'

Vue.use(VueRouter)
const routes = [{
  path: '/',
  redirect: '/layout' // 重定向
},
{
  path: '/login',
  component: Login
}, {
  path: '/layout',
  component: Layout,
  redirect: '/layout/home',
  children: [
    {
      // path:'' ,或者重定向
      path: 'home',
      component: Home
    }, {
      path: 'user',
      component: User
    }
  ]
},
{
  path: '/search',
  component: Search
}, {
  // 搜索结果页
  path: '/search/:keyword', // 动态路由
  // name: 'resultlist',
  component: SearchResultList
}, {
  // 文章详情页
  path: '/article',
  component: ArticleDetail
}, {
  path: '/user/edit',
  component: UserEdit
},
{
  path: '/chat',
  component: Chat
}
]

const router = new VueRouter({
  routes
})

export default router
